import {http} from '@/utils/http/axios';

export interface BasicResponseModel<T = any> {
  code: number;
  message: string;
  meta: T;
}

export interface BasicPageParams {
  pageNumber: number;
  pageSize: number;
  total: number;
}

export interface AddAdminUserParams {
  chanList: string;
  createTime: string;
  desc: string;
  firstPsIds: string;
  id: number;
  password: string;
  phone: string;
  roleType: string;
  secondPsIds: string;
  status: string;
  updateTime: string;
  username: string;
}

/**
 * @description: 获取用户信息
 */
// export function getUserInfo() {
//   return http.request({
//     url: '/admin_info',
//     method: 'get',
//   });
// }

/**
 * @description: 用户登录
 */
export function login(params) {
  return http.request<BasicResponseModel>(
    {
      url: '/system/login',
      method: 'POST',
      params,
    },
    {
      isTransformResponse: false,
    }
  );
}

/**
 * @description: 用户修改密码
 */
export function changePassword(params) {
  return http.request(
    {
      url: '/system/user/pswChange',
      method: 'POST',
      params,
    },
  );
}

/**
 * @description: 用户登出
 */
export function logout(params) {
  return http.request({
    url: '/login/logout',
    method: 'POST',
    params,
  });
}

/**
 * 添加管理员用户
 * @param params
 */
export function addAdminUser(params: AddAdminUserParams) {
  return http.request({
    url: '/system/user/regist',
    method: 'POST',
    params,
  });
}

/**
 * 删除管理员用户
 */
export function deleteAdminUser(params) {
  return http.request({
    url: '/system/user/delete',
    method: 'POST',
    params,
  });
}

export function getSystemUserList() {
  return http.request({
    url: '/system/user/all',
    method: 'GET',
  });
}

export function updateSystemUser(params) {
  return http.request({
    url: '/system/user/update',
    method: 'POST',
    params,
  });
}
